package com.bolehui.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bolehui.base.result.Result;
import com.bolehui.domain.po.Portfolio;
import com.bolehui.domain.vo.PortFolioVO;
import com.bolehui.mapper.PortfolioMapper;
import com.bolehui.service.PortfolioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author chendongjie
 * @since 2025-03-18
 */
@Service
public class PortfolioServiceImpl extends ServiceImpl<PortfolioMapper, Portfolio> implements PortfolioService {

    @Autowired
    private PortfolioMapper portfolioMapper;
    @Override
    public Result savePortf(PortFolioVO portFolioVO, Long userId) {
        Portfolio portfolio = Portfolio.builder()
                .projectDesc(portFolioVO.getProjectDesc())
                .projectLink(portFolioVO.getProjectLink())
                .projectName(portFolioVO.getProjectName())
                .candidateId(userId)
                .build();
        portfolioMapper.insert(portfolio);
        return Result.success();
    }

    @Override
    public Result update(PortFolioVO portFolioVO, Long userId) {
        Portfolio portfolio = Portfolio.builder()
                .projectDesc(portFolioVO.getProjectDesc())
                .projectLink(portFolioVO.getProjectLink())
                .projectName(portFolioVO.getProjectName())
                .build();
        portfolioMapper.update(portfolio, new QueryWrapper<Portfolio>().eq("candidate_id", userId));
        return Result.success();
    }
}
